﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reflection;
using System.Text;
using Cloak.Reflection;

namespace Ruleweaver.Rules.CheckMethods
{
	public sealed class StringContainsMethod : SingleTypeCheckMethod
	{
		private readonly string _value;

		public StringContainsMethod(string value)
		{
			Contract.Requires(value != null);

			_value = value;
		}

		protected override Type TargetType
		{
			get { return typeof(string); }
		}

		protected override MethodInfo GetMethod(Type checkType)
		{
			return Reflect.Func<ICheckable<string>, string, Check<string>>(Checkable.Contains);
		}

		protected override IEnumerable<object> GetCheckArguments()
		{
			yield return _value;
		}
	}
}